# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

class FT_07b5:
    
    Data_array1 = [["环境温度","4"],["大气压力","2"],["发动机转速","4"],["油门踏板位置","2"],["车速","4"],["发动机累计燃油消耗量","8"],["累计里程","8"],["脚刹","2"],["发动机实际扭矩百分比","2"],["摩擦力扭矩","2"],["发动机参考扭矩","4"],["发动机累计工作时间","8"],["发动机冷却液温度","2"],["MIL","2"],["SCR催化剂罐液位","2"],["SCR催化剂罐温度","2"],["排气氮氧测量值","4"],["催化剂下游温度","4"],["排气温度(DPF/POC)","4"],["载体压差(DPF/POC)","4"]]

    analysis07b3Length = [2, 6, 4, 4]
    analysis07b3 = ["自定义消息体长度:", "采集时间:", "纬度:", "经度:"]


    protocolStr = ''
    messageLength = []  # 自定义消息体长度
    collectTime = '' #采集时间
    latitude = ''#纬度
    longitude = ''#经度
    data_g_str1 = '' #数据组1
    result = []

    def LogicAisle(self, protocol, header):
        self.result = header
        self.protocolStr = protocol
        self.Init()
        print"setLongitudeend"
        self.result.append(self.analysis07b3[0] + self.messageLength + '\n')    # 自定义消息体长度
        self.result.append(self.analysis07b3[1] + self.collectTime + '\n')   # 采集时间
        self.result.append(self.analysis07b3[2] + self.latitude + '\n')   # 纬度
        self.result.append(self.analysis07b3[3] + self.longitude + '\n')   # 经度
        print"setLongitudeendzzzzzz"
        self.data_g_str1 = self.protocolStr[32:106]
        flag1 = self.Data_array1
        startPoint1=0
        for i in range(len(flag1)):
            dataarrayLen = flag1[i][1]
            print type(startPoint1)
            print type(int(dataarrayLen))
            endPoint = startPoint1+int(dataarrayLen)
            tmpdata = self.data_g_str1[startPoint1:endPoint]
            print type(flag1[i][0])
            print "flag1[i][0]",(flag1[i][0])
            self.result.append(flag1[i][0] + tmpdata + '\n')
            startPoint1 = endPoint
            
    def Init(self):
        self.setMessageLength()
        self.setCollectTime()
        self.setLatitude()
        self.setLongitude()
    def setMessageLength(self):
        self.messageLength = self.protocolStr[0:4]
        print"setMessageLength"
    def setCollectTime(self):
        self.collectTime = self.protocolStr[4:16]
        print"setCollectTime"
    def setLatitude(self):
        self.latitude = self.protocolStr[16:24]
        print"setLatitude"
    def setLongitude(self):
        self.longitude = self.protocolStr[24:32]
        print"setLongitude"
